Retrieving Results Using :DATA:FDAT{1-4}?

Other topics about Sample Programs

Overview

This sample program is useful when you trigger the instrument without using an external controller or when you need to perform a particular task between triggering and retrieval.

The program demonstrates the use of the :DATA:FDAT{1-4}? command which returns the measurement data from the most recently performed measurement.

See these topics for this programming:

Sample program in Excel VBA Using VISA-COM

Sub DATA_FDATA()

    '*** The variables of the resource manager and the instrument I/O are declared

    Dim ioMgr As VisaComLib.ResourceManager

    Dim Age4982x As VisaComLib.FormattedIO488

    '*** The memory area of the resource manager and the instrument I/O are acquired

    Set ioMgr = New VisaComLib.ResourceManager

    Set Age4982x = New VisaComLib.FormattedIO488

    '*** Open the instrument & sets the GPIB address

    Set Age4982x.IO = ioMgr.Open("GPIB0::17::INSTR")

    Age4982x.IO.timeout = 30000   ' Timeout time should be greater than the measurement time.

    

    MsgBox ("4982X is Open!"), vbOKOnly

    

    '*** Variable declaration

    Dim Para1, Para2, Buff As String

    Dim Res1, Res2, Imon As String

    Dim Point, Scode As Integer

    Dim Result() As Double

    Scode = 7

    

    '* Sets the Point variable to the number of measurement points for single-point measurement.

    Point = 1

    

    '* Sets the data transfer format to ASCII.

    Age4982x.WriteString ":FORM ASC", True

    

    '* Retrieves the parameter names of measurement parameters 1 and 2

    '*  and stores the names into the Para1$ and Para2$ variables, respectively.

    Age4982x.WriteString ":CALC:PAR1:FORM?", True

    Para1 = Age4982x.ReadString

    Age4982x.WriteString ":CALC:PAR2:FORM?", True

    Para2 = Age4982x.ReadString

    

    '* Instructs the instrument to perform single-point measurement at the

    '*  point identified by the Point variable.

    Age4982x.WriteString ":SOUR:LIST:STAT OFF", True

    Age4982x.WriteString ":SOUR:LIST:POIN " & Point, True

        

    '*** Trigger source setting.

    '* After measurement is stopped (the trigger system is stopped), the

    '*  program sets the trigger source to External trigger and turns on the

    '*  continuous activation of the trigger system.

    Age4982x.WriteString ":ABOR", True

    Age4982x.WriteString ":TRIG:SOUR EXT", True

    Age4982x.WriteString ":INIT:CONT ON", True

    

    '*** Status register setting (For SRQ)

    '* Instructs the instrument to generate an SRQ upon completion of

    '*  measurement and clears the status byte register and operation status

    '*  event register.

    Age4982x.WriteString ":STAT:OPER:PTR 0", True

    Age4982x.WriteString ":STAT:OPER:NTR 16", True

    Age4982x.WriteString ":STAT:OPER:ENAB 16", True

    Age4982x.WriteString "*SRE 128", True

    Age4982x.WriteString "*CLS", True

    Age4982x.WriteString "*OPC?", True

    Buff = Age4982x.ReadString

        

    '* Triggers and reads data. Prompts the user to input an external trigger. The program waits until

    '*  the instrument receives an external trigger and completes the measurement cycle.

    MsgBox "Waiting for external trigger...", vbOKOnly

    '* Retrieves the measurement results for parameters 1 and 2 and the

    '*  result of test signal current level monitoring and stores the data into the

    '*  Res1, Res2, and Imon variables, respectively.

        

    Age4982x.WriteString ":DATA:FDAT1?", True

    Res1 = Age4982x.ReadString

    Age4982x.WriteString ":DATA:FDAT2?", True

    Res2 = Age4982x.ReadString

    Age4982x.WriteString ":DATA:IMON?", True

    Imon = Age4982x.ReadString

    

    '*** Displays the measurement results

    MsgBox "### Result ###", vbOKOnly

    MsgBox ("Meas. Status: " & vbCrLf & "Para1: " & Para1 & "Result: " & Res1 & "Para2: " & Para2 & "Result: " & Res2 & "Imon : " & Imon), vbOKOnly, "Measurement Results"

    MsgBox ("End of ""Retrieving Results Using :DATA:FDAT{1-4}"" program"), vbOKOnly

    

End Sub